package edu.wuster.blog.mapper;


import edu.wuster.blog.entity.Blogpart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDate;
import java.util.List;



@Mapper
public interface SearchMapper {

    //用户查看个人博客
    @Select("select * from blog where author = #{author} ")
    List<Blogpart> selectByAuthor(String author);

    //根据标签搜索博客
    @Select("select * from blog join label on blog.id = label.blog_id where label.name = #{name} ")
    List<Blogpart> selectByLabel(String name);

    //用户在个人博客范围内模糊搜索
    @Select("select * from blog where title like '%${mohu}%'and author = #{author}")
    List<Blogpart> userSelectMohu(String mohu,String author);

    //首页根据标题模糊搜索,限制状态“已发布”
    List<Blogpart> homeSelectMohu(String title, Integer likeNum, LocalDate begin, LocalDate end);

    //管理员搜索
    List<Blogpart> selectByAdmin(String title, String state, LocalDate begin, LocalDate end);

}
